#include "Driver_Delay.h"

void Delay_Ms(uint16_t ms)
{
  uint32_t temp;
  SysTick->LOAD = (uint32_t)ms * 6000;
  SysTick->VAL = 0x00;
  SysTick->CTRL = 0x01;
  do
  {
    temp = SysTick->CTRL;
  } while (temp & 0x01 && !(temp & (1 << 16)));
  SysTick->CTRL = 0x00;
  SysTick->VAL = 0x00;
}

void Delay_Us(uint16_t us)
{
  uint32_t temp;
  SysTick->LOAD = (uint32_t)us * 6;
  SysTick->VAL = 0x00;
  SysTick->CTRL = 0x01;
  do
  {
    temp = SysTick->CTRL;
  } while (temp & 0x01 && !(temp & (1 << 16)));
  SysTick->CTRL = 0x00;
  SysTick->VAL = 0x00;
}
